# -*- coding: utf-8 -*-

from datetime import datetime

from loguru import logger


def current_time():
    """当前时间"""
    return datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')


def safe(func):
    """捕获异常"""

    def _safe(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            logger.error('{} ==> {}'.format(func.__name__, e))

    return _safe
